package com.atguigu.guliguli.product.service.impl;

import com.atguigu.guliguli.product.entity.AttrAttrgroupRelationEntity;
import com.atguigu.guliguli.product.mapper.AttrAttrgroupRelationMapper;
import com.atguigu.guliguli.product.service.AttrAttrGroupRelationService;
import com.atguigu.guliguli.product.vo.AttrGroupRelationVo;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.BeanUtils;

import java.util.List;
import java.util.stream.Collectors;

/**
 * @author: 叶子
 * @date: 2021/12/19 22:47
 **/
public class AttrAttrGroupRelationServiceImpl extends ServiceImpl<AttrAttrgroupRelationMapper, AttrAttrgroupRelationEntity> implements AttrAttrGroupRelationService {
    @Override
    public void saveBatch(List<AttrGroupRelationVo> vos) {
        List<AttrAttrgroupRelationEntity> collect = vos.stream().map(item -> {
            AttrAttrgroupRelationEntity relationEntity = new AttrAttrgroupRelationEntity();
            BeanUtils.copyProperties(item, relationEntity);
            return relationEntity;
        }).collect(Collectors.toList());
        this.saveBatch(collect);
    }
}